package cn.jeefast.modules.platform.controller;


import cn.jeefast.common.entity.MbResBsaseInfo;
import cn.jeefast.common.utils.R;
import cn.jeefast.modules.platform.service.MbResBsaseInfo1Service;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import cn.jeefast.common.base.BaseController;
import springfox.documentation.annotations.Cacheable;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author theodo
 * @since 2020-01-11
 */
@RestController
@RequestMapping("/mbResBsaseInfo")
@CrossOrigin
public class MbResBsaseInfo1Controller extends BaseController {
    @Autowired
	private MbResBsaseInfo1Service mbResBsaseInfo1Service;

    @RequestMapping("/list")
    public R list(Long resId,Long projId){
        EntityWrapper ew = new EntityWrapper();
        ew.eq("res_id",resId);
        ew.eq("proj_id",projId);
        List list = mbResBsaseInfo1Service.selectList(ew);
        return R.ok().put("data",list.get(0));
    }

    @RequestMapping("/addOrSave")
    public R addOrSave(MbResBsaseInfo mbResBsaseInfo){
        if(mbResBsaseInfo.getId()==null){
            mbResBsaseInfo1Service.insert(mbResBsaseInfo);
        }else{
            mbResBsaseInfo1Service.updateById(mbResBsaseInfo);
        }
        return R.ok();
    }
}
